package com.example.demo.design.demo20_iterator;

/**
 * Created by 蔡超 on 2018/10/4.
 */
public class Client {
    public static void main(String[] args) {
        Aggregate aggregate = new ConcreteAggregate();
        aggregate.add("aa");
        aggregate.add("b");
        aggregate.add("cc");
        Iterator iterator = aggregate.createIterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }

        aggregate.add("ee");
        aggregate.add("ff");
        Iterator iterator2 = aggregate.createIterator();
        while (iterator2.hasNext()){
            System.out.println(iterator2.next());
        }

    }
}
